package com.imooc.error;

import com.imooc.enums.CommonEnum;

public class BusinessException extends RuntimeException implements CommonEnum {

    private final CommonEnum commonEnum;

    public BusinessException(CommonEnum commonEnum) {
        this.commonEnum = commonEnum;
    }

    public BusinessException(CommonEnum commonEnum, String msg) {
        this.commonEnum = commonEnum;
        this.commonEnum.setMsg(msg);
    }

    @Override
    public int getCode() {
        return this.commonEnum.getCode();
    }

    @Override
    public String getMsg() {
        return this.commonEnum.getMsg();
    }

    @Override
    public CommonEnum setMsg(String errMsg) {
        this.commonEnum.setMsg(errMsg);
        return this;
    }
}
